﻿using System;

namespace Budgetsch.WP7.Model.Live
{
    using System.Collections.Generic;

    using Budgetsch.WP7.Model.DataService;
    using Budgetsch.WP7.ViewModel;
    using Budgetsch.WP7.WP7DataService;

    public class PublicDataService:IPublicDataService
    {
        private readonly CookieContainerViewModel _cookieContainerViewModel;

        public PublicDataService(CookieContainerViewModel cookieContainerViewModel)
        {
            _cookieContainerViewModel = cookieContainerViewModel;
        }

        #region Implementation of IPublicDataService

        public void GetPublicUsers(Action<IEnumerable<User>, Exception> callback)
        {
            var client = new WP7DataServiceClient { CookieContainer = _cookieContainerViewModel.CookieContainer };
            client.GetPublicUsersCompleted += (s, e) => callback(e.Result, e.Error);
            client.GetPublicUsersAsync();
        }

        #endregion
    }
}
